// ignore_for_file: prefer_typing_uninitialized_variables

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:verse_systems/commom/routers/custom_route_animation.dart';
import 'package:verse_systems/commom/routers/navigator_utils.dart';
import 'package:verse_systems/pages/mine/mie_languages_set.dart';
import 'package:verse_systems/pages/mine/mine_control.dart';
import 'package:verse_systems/res/colors.dart';

import 'package:verse_systems/widgets/customize_mine_appbar.dart';
import 'package:verse_systems/widgets/customize_mine_card.dart';
import 'package:verse_systems/widgets/sp_button.dart';

class MinePage extends StatefulWidget {
  const MinePage({super.key});

  @override
  State<MinePage> createState() => _MinePageState();
}

class _MinePageState extends State<MinePage> {
  final control = Get.put(MineControl());
  final state = Get.find<MineControl>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colours.system_background_color,
        body: GetBuilder<MineControl>(
            init: control,
            builder: (_) {
              return SingleChildScrollView(
                child: Column(
                  children: [
                    CustomizeMienAppbar(
                      phone: state.info!["phone"].toString(),
                      real_name: state.info!["real_name"].toString(),
                      credit_score: state.info!["credit_score"].toString(),
                      quota: state.info!["quota"].toString(),
                      rate: state.info!["rate"].toString(),
                      contact: control.onTapContact,
                      logout: control.onTapLogOut,
                      onTapVip: control.onTapVip,
                    ),
                    CustomizeMineCard(
                      onTapCard: control.onTapCard,
                    ),
                    _userLanguage,
                    Container(
                      margin: EdgeInsets.fromLTRB(0, 105.w, 0, 0),
                      width: 145.w,
                      child: SPButton(
                          minHeight: 35.w,
                          fontSize: 13.sp,
                          text: "account_logout".tr,
                          textColor: Colours.app_line_color,
                          backgroundColor: Colours.app_logoff_text_color,
                          radius: 17.5.w,
                          onPressed: () {
                            control.onTapCard(4);
                          }),
                    ),
                  ],
                ),
              );
            }));
  }

  Widget get _userLanguage {
    return Container(
      margin: EdgeInsets.symmetric(
        horizontal: (MediaQuery.of(context).size.width - 330.w) / 2,
      ),
      padding: EdgeInsets.symmetric(horizontal: 20.w),
      width: 330.w,
      height: 50.w,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(8.w)),
        color: Colours.app_main_color,
      ),
      child: InkWell(
        onTap: () {
          Navigator.push(NavigatorUtils.context,
              CustomRouteAnimation(routePage: const MieLanguagesSet()));
        },
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text(
              "hand_languages".tr,
              style: TextStyle(
                  fontSize: 13.sp,
                  color: Colours.app_text_color,
                  fontWeight: FontWeight.w500),
            ),
            Icon(
              Icons.arrow_forward_ios_rounded,
              color: Colours.app_line_color,
              size: 16.w,
            )
          ],
        ),
      ),
    );
  }
}
